package osami.communication.translate;

import java.util.Vector;

import osami.communication.OsamiIdentifier;

public class RemoteCallMessage extends Message
{
	protected String iInterfaceName = null;
	protected String iMethodName = null;
	protected Vector<Object> iParameters = null;
	protected Vector<OsamiIdentifier> iRoute = null;
	protected Vector<OsamiIdentifier> iCallPath = new Vector<OsamiIdentifier>();

	public RemoteCallMessage( int aCallNumber, String aInterfaceName, String aMethodName )
	{
		iCallNumber = aCallNumber;
		iInterfaceName = aInterfaceName;
		iMethodName = aMethodName;
	}
	
	
	public void setParameters( Vector<Object> aParameters )
	{
		iParameters = aParameters;
	}
	
	
	public Vector<Object> getParameters()
	{
		return iParameters;
	}
	
	
	public void setRoute( Vector<OsamiIdentifier> aRoute )
	{
		iRoute = aRoute;
	}
	
	
	public void setCaller( OsamiIdentifier aCaller )
	{
		iCallPath = new Vector<OsamiIdentifier>();
		iCallPath.add( aCaller );
	}
	
	
	public void addToCallPath( OsamiIdentifier aCaller )
	{
		iCallPath.add( aCaller );
	}
	
	
	public String getInterfaceName()
	{
		return iInterfaceName;
	}
	
	
	public void setInterfaceName( String aInterfaceName )
	{
		iInterfaceName = aInterfaceName;
	}
	
	
	public String getMethodName()
	{
		return iMethodName;
	}
	
	
	public void setMethodName( String aMethodName )
	{
		iMethodName = aMethodName;
	}

	
	public Vector<OsamiIdentifier> getCallPath()
	{
		return iCallPath;
	}

	
	public void setCallPath( Vector<OsamiIdentifier> aCallPath )
	{
		iCallPath = aCallPath;
	}
	
	
	public OsamiIdentifier getSender()
	{
		return iCallPath.get( iCallPath.size() - 1 );
	}
	
	
	public int getType()
	{
		return Message.REMOTE_CALL;
	}

	
	public Vector<OsamiIdentifier> getRoute()
	{
		return iRoute;
	}
	
	
	public OsamiIdentifier popFirstFromRoute()
	{
		if ( iRoute.size() > 0 )
			return iRoute.remove(0);
		
		return null;
	}
	
	
	public OsamiIdentifier getDestination()
	{
		if ( iRoute.size() > 0 )
			return iRoute.get(0);
		
		return null;
	}
	
	
	public boolean isRequest()
	{
		return true;
	}
}
